package com.equipment;

import android.annotation.SuppressLint;
import com.util.EncodingUtil;

/**
 * 检测OBU指令 AA
 * @version 1.18
 * @author 刘亚东
 *
 */
@SuppressLint("DefaultLocale")
public class DetectionOBURequest {
	private String STX = "55AA"; // 帧开始标志
	private String RSCTL = "00"; // 串口帧序列号
	private String Length=""; //长度
	private String code = "FD"; // 代码
	private String broadening = "AA"; // 扩展代码
	private String BstUnixTime="";//BST中的Unixtime(4字节)
	private String BCC = ""; // 异或校验值

	/**
	 * 发送AA指令 检测OBU指令
	 *
	 * @return
	 */
	public String command() {
		this.BstUnixTime=EncodingUtil.LongTosix(System.currentTimeMillis()/1000, 8).toUpperCase();
		Length=EncodingUtil.desToHex((broadening+BstUnixTime).length()/2, 4);
		// DATA由代码+扩展子代码+目录编号
		String DATA =RSCTL+Length+ code + broadening+BstUnixTime;
		// 异或校验从RSCTL到DATA所有字节的异或值
		BCC = EncodingUtil.yihuo(EncodingUtil.change(DATA));
		String retn = STX + DATA+BCC ; // 拼接完整的请求
		return retn;
	}

	public String getSTX() {
		return STX;
	}

	public void setSTX(String sTX) {
		STX = sTX;
	}

	public String getRSCTL() {
		return RSCTL;
	}

	public void setRSCTL(String rSCTL) {
		RSCTL = rSCTL;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getBroadening() {
		return broadening;
	}

	public void setBroadening(String broadening) {
		this.broadening = broadening;
	}

	public String getBCC() {
		return BCC;
	}

	public void setBCC(String bCC) {
		BCC = bCC;
	}

	public String getLength() {
		return Length;
	}

	public void setLength(String length) {
		Length = length;
	}

	public String getBstUnixTime() {
		return BstUnixTime;
	}

	public void setBstUnixTime(String bstUnixTime) {
		BstUnixTime = bstUnixTime;
	}


}
